Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Draft] Fix BIRPackage.importModules containing duplicate elements #42346

Conversation

Thushara-Piyasekara
Copy link
Contributor

@Thushara-Piyasekara Thushara-Piyasekara commented Mar 19, 2024

Purpose

Describe the problems, issues, or needs driving this feature/fix and include links to related issues.

Fixes #42343

Approach

Restricted the addition of duplicate elements by the usage of a HashSet instead of an ArrayList and setting up the necessary equals() and hashCode() functions for the BIRImportModule class. This will filter the duplicate imports after the BIR Gen phase.

Samples

Provide high-level details about the samples related to this feature.

Remarks

The root cause of the duplicate imports is in the AST level. The duplicate imports originally derive from the import statements in .bal files. Since a ballerina project can have more than one .bal file it produces more than one BLangImportPackage.

image

These AST level imports are used by the DataflowAnalyzer to detect unused imports. Therefore duplicates are needed in AST level.

Due to above reasoning, the safe choice is to omit them during the BIR Gen phase.

Check List

  • Read the Contributing Guide
  • Updated Change Log
  • Checked Tooling Support (#)
  • Added necessary tests
    • Unit Tests
    • Spec Conformance Tests
    • Integration Tests
    • Ballerina By Example Tests
  • Increased Test Coverage
  • Added necessary documentation
    • API documentation
    • Module documentation in Module.md files
    • Ballerina By Examples

@Thushara-Piyasekara Thushara-Piyasekara marked this pull request as ready for review March 21, 2024 08:12
Copy link

codecov bot commented Mar 22, 2024

Codecov Report

Attention: Patch coverage is 42.85714% with 4 lines in your changes missing coverage. Please review.

Project coverage is 78.07%. Comparing base (b35b99e) to head (5524c7c).
Report is 1883 commits behind head on dedup-birpkg-imports.

Files with missing lines Patch % Lines
...wso2/ballerinalang/compiler/bir/model/BIRNode.java 42.85% 2 Missing and 2 partials ⚠️
Additional details and impacted files
@@                    Coverage Diff                     @@
##             dedup-birpkg-imports   #42346      +/-   ##
==========================================================
+ Coverage                   76.50%   78.07%   +1.56%     
- Complexity                  53177    58685    +5508     
==========================================================
  Files                        2892     3492     +600     
  Lines                      201001   232268   +31267     
  Branches                    26189    32768    +6579     
==========================================================
+ Hits                       153776   181336   +27560     
- Misses                      38765    41432    +2667     
- Partials                     8460     9500    +1040     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link

github-actions bot commented Apr 6, 2024

This PR has been open for more than 15 days with no activity. This will be closed in 3 days unless the stale label is removed or commented.

@github-actions github-actions bot added the Stale label Apr 6, 2024
Copy link

Closed PR due to inactivity for more than 18 days.

Copy link

This PR has been open for more than 15 days with no activity. This will be closed in 3 days unless the stale label is removed or commented.

@github-actions github-actions bot added the Stale label Jul 13, 2024
Copy link

Closed PR due to inactivity for more than 18 days.

@github-actions github-actions bot closed this Jul 17, 2024
@gimantha gimantha removed the Stale label Sep 6, 2024
@gimantha gimantha reopened this Sep 6, 2024
@gimantha gimantha changed the title Fix BIRPackage.importModules containing duplicate elements [Draft] Fix BIRPackage.importModules containing duplicate elements Sep 10, 2024
@gimantha gimantha marked this pull request as draft September 10, 2024 03:34
@gimantha gimantha changed the base branch from master to dedup-birpkg-imports October 8, 2024 09:47
@gimantha gimantha marked this pull request as ready for review October 8, 2024 09:49
@gimantha gimantha closed this Oct 8, 2024
@gimantha gimantha reopened this Oct 8, 2024
@gimantha gimantha merged commit 90b8860 into ballerina-platform:dedup-birpkg-imports Oct 8, 2024
29 of 34 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Improvement]: Optimize BIRPackage.importModules to not contain duplicate BIRImportModule elements
4 participants